package us.wili.dev.client.model.rsp;

import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import us.wili.dev.common.model.IdLongToStrSerializer;
import us.wili.dev.model.entity.Collection;
import us.wili.dev.model.entity.Goods;
import us.wili.dev.model.entity.Order;
import us.wili.dev.model.entity.Shopcart;

import java.math.BigDecimal;


public class ShopcartRsp {
    @ApiModelProperty(value="id")
    @JSONField(serializeUsing = IdLongToStrSerializer.class)
    private Long Id;

    @ApiModelProperty(value="商品id")
    private Long goodsId;

    @ApiModelProperty(value="商品价格")
    private BigDecimal goodsPrice;

    @ApiModelProperty(value="商品名字")
    private String goodsName;

    @ApiModelProperty(value="商品主图")
    private String goodsPic;

    @ApiModelProperty(value="商品颜色")
    private Integer goodsColor;

    @ApiModelProperty(value="商品")
    private Goods goods;

    @ApiModelProperty(value="商品数量")
    private Integer goodsNum;

    @ApiModelProperty(value="收藏日期")
    private String time;

    public static ShopcartRsp ToShopCart(Goods goods,Shopcart shopcart){
        ShopcartRsp rsp =new ShopcartRsp();
        rsp.setId(shopcart.getId());
        rsp.setGoodsId(goods.getId());
        rsp.setGoodsPic(goods.getGoodsPic());
        rsp.setGoodsName(goods.getGoodsName());
        rsp.setGoodsPrice(goods.getGoodsPrice());
        rsp.setGoodsColor(goods.getGoodsColor());
        rsp.setGoodsNum(shopcart.getGoodsNum());
        return rsp;
    }

    public static ShopcartRsp ToOrder(Goods goods,Order order){
        ShopcartRsp rsp =new ShopcartRsp();
        rsp.setGoodsId(goods.getId());
        rsp.setGoodsPic(goods.getGoodsPic());
        rsp.setGoodsName(goods.getGoodsName());
        rsp.setGoodsPrice(goods.getGoodsPrice());
        rsp.setGoodsColor(goods.getGoodsColor());
        return rsp;
    }

    public static ShopcartRsp ToCollection(Goods goods,Collection collection){
        ShopcartRsp rsp =new ShopcartRsp();
        rsp.setGoodsId(goods.getId());
        rsp.setGoodsPic(goods.getGoodsPic());
        rsp.setGoodsName(goods.getGoodsName());
        rsp.setGoodsPrice(goods.getGoodsPrice());
        rsp.setGoodsColor(goods.getGoodsColor());
        rsp.setTime(collection.createdAtToDatetime());
        return rsp;
    }

    public Long getId() {
        return Id;
    }

    public void setId(Long id) {
        Id = id;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public Integer getGoodsNum() {
        return goodsNum;
    }

    public void setGoodsNum(Integer goodsNum) {
        this.goodsNum = goodsNum;
    }

    public Integer getGoodsColor() {
        return goodsColor;
    }

    public void setGoodsColor(Integer goodsColor) {
        this.goodsColor = goodsColor;
    }

    public Goods getGoods() {
        return goods;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    public Long getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Long goodsId) {
        this.goodsId = goodsId;
    }

    public BigDecimal getGoodsPrice() {
        return goodsPrice;
    }

    public void setGoodsPrice(BigDecimal goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsPic() {
        return goodsPic;
    }

    public void setGoodsPic(String goodsPic) {
        this.goodsPic = goodsPic;
    }
}
